package com.example.exam.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfigure implements WebMvcConfigurer {
    @Bean
        /** 
            * @Description:  
            * @Param: [] 
            * @return: org.springframework.web.servlet.config.annotation.InterceptorRegistry 
            * @Author: xhw
            * @Date: 2021/7/26 
            */ 
    public InterceptorRegistry interceptorRegistry(){
        return new InterceptorRegistry();
    }
        @Override
            /** 
                * @Description:  配置项目的拦截页面和不拦截页面
                * @Param: [registry] 
                * @return: void 
                * @Author: xhw
                * @Date: 2021/7/26 
                */ 
        public void addInterceptors(InterceptorRegistry registry){
            /*registry.addInterceptor(new TestInterceptor())
                    .addPathPatterns("/**")
                    .excludePathPatterns("/", "/index.html", "../css/**", "../js/**");*/
            InterceptorRegistration ir=registry.addInterceptor(new TestInterceptor());
            ir.addPathPatterns("/**");
            ir.excludePathPatterns("/user/toLogin");
            ir.excludePathPatterns("/");
            ir.excludePathPatterns("/user/login");
            ir.excludePathPatterns("/user/login.js");
            ir.excludePathPatterns("/system/**");
        }
}
